#include <cmath>
#include <iostream>
#include <list>
using namespace std;

struct node {
    node* next;
    int x1, y1, x2, y2;
    int id;
    node(): next(NULL) {}
    node(int x1, int y1, int w, int h, int id): x1(x1), y1(y1), x2(x1 + w),
        y2(y1 + h), id(id), next(NULL) {}
};

bool isIn(int x, int y, node* window) {
    return x >= window->x1 && x <= window->x2 && y >= window->y1 && y <= window->y2;
}
int main() {
    int n;
    int m;
    cin >> n >> m;
    node* head = new node(0, 0, 0, 0, 0);
    node* cur = head;
    for (int i = 0; i < n; i++) {
        int x;
        int y;
        int w;
        int h;
        cin >> x >> y >> w >> h;
        node* tmp = new node(x, y, w, h, i + 1);
        tmp->next = head->next;
        head->next = tmp;
    }
    while (m--) {
        int chickx;
        int chicky;
        cur = head->next;
        scanf("%d%d", &chickx, &chicky);
        node* cur = head->next, *pre = head;
        while (cur && !isIn(chickx, chicky, cur)) {
            pre = cur;
            cur = cur->next;
        }
        if (!cur) puts("-1");
        else {
            printf("%d\n", cur->id);
            if (pre != head) {
                pre->next = cur->next;
                cur->next = head->next;
                head->next = cur;
            }
        }
    }
}
// 64 位输出请用 printf("%lld")